<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>子标准条款维护信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/systemStatic/style/admin.css">
    <link rel="stylesheet" href="/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="/css/public.css">
    <script type="text/javascript">
        var __ctx = "";
    </script>
</head>
<body>

<div style="margin: 10px">
    <table id="wZbztkbTable" lay-filter="wZbztkbTable"></table>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wZbztkbHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <a class="layui-btn layui-btn-sm" lay-event="add">
                <i class="layui-icon layui-icon-add-1"></i>
                <span>新增</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="delete">
                <i class="layui-icon layui-icon-delete"></i>
                <span>删除</span>
            </a>
            <!--<a class="layui-btn layui-btn-sm" lay-event="export">
                <i class="layui-icon layui-icon-export"></i>
                <span>导出</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="import">
                <i class="layui-icon layui-icon-download-circle"></i>
                <span>导入</span>
            </a>-->
            <a class="layui-btn layui-btn-sm" lay-event="query">
                <i class="layui-icon layui-icon-search"></i>
                <span>查询</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="clears">
                <i class="layui-icon layui-icon-refresh"></i>
                <span>重置</span>
            </a>
        </div>
        <form class="layui-form" action="" lay-filter="wZbztkbQueryForm" style="margin-right: 30px;">
            <div class="layui-row" style="margin-top: 10px;">
                <div class="selch table-top-filter">
                    <!-- <div class="table-filter-alone">
                             <label class="layui-form-label">dicid</label>
                             <input type="text" class="layui-input filter-value" name="Q_dicid_SL" placeholder="dicid"/>
                     </div>
                     <div class="table-filter-alone">
                             <label class="layui-form-label">typeid</label>
                             <input type="text" class="layui-input filter-value" name="Q_typeid_SL" placeholder="typeid"/>
                     </div>-->
                    <!--<div class="table-filter-alone">
                        <label class="layui-form-label">标准条款代码</label>
                        <input type="text" class="layui-input filter-value" name="Q_itemkey_SL"/>
                    </div>-->
                    <div class="table-filter-alone">
                        <label class="layui-form-label">子标准条款</label>
                        <input type="text" class="layui-input filter-value" name="Q_itemname_SL"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label" style="width: 150px;">子标准条款内容</label>
                        <input type="text" class="layui-input filter-value" name="Q_itemvalue_SL"/>
                    </div>
                    <!--<div class="table-filter-alone">
                        <label class="layui-form-label">description</label>
                        <input type="text" class="layui-input filter-value" name="Q_description_SL" placeholder="description"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">sn</label>
                        <input type="text" class="layui-input filter-value" name="Q_sn_L" placeholder="sn"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">nodepath</label>
                        <input type="text" class="layui-input filter-value" name="Q_nodepath_SL" placeholder="nodepath"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">parentid</label>
                        <input type="text" class="layui-input filter-value" name="Q_parentid_SL" placeholder="parentid"/>
                    </div>-->
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wZbztkbRightToolsBar">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs" lay-event="particulars">详情</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script src="/public/component.js" type="text/javascript"></script>
<script src="/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index', 'table', 'setter', 'form', 'common', 'totalFilter', 'commons', 'jquery', 'layer'], function () {
        var table = layui.table;
        var setter = layui.setter;
        var form = layui.form;
        var common = layui.common;
        var commons = layui.commons;
        var $ = layui.jquery;
        var layer = layui.layer;
        var totalFilter = layui.totalFilter;
        common.tableSort('wZbztkbTable');

        var tableH = commons.tabHeight();

        //第一个实例
        table.render({
            elem: '#wZbztkbTable'
            , height: tableH
            , url: serverPath.basePath + '/qbdms/wZbztkb/list'
            , page: true //开启分页
            , toolbar: '#wZbztkbHeaderToolsBar'
            , method: 'post'
            , autoSort: false //是否排序
            , cols: [[ //表头
                // {field: 'sn', type: 'numbers', title: '序号', fixed: 'left'},
                {type: 'checkbox', fixed: 'left'}
                // , {field: 'dicid', title: 'dicid', sort: true, sortname: 'dicid'}
                // , {field: 'typeid', title: 'typeid', sort: true, sortname: 'typeid'}
                , {field: 'itemkey', title: '标准条款代码', sort: true, sortname: 'itemkey'}
                , {field: 'itemname', title: '子标准条款', sort: true, sortname: 'itemname'}
                , {field: 'itemvalue', title: '子标准条款内容', sort: true, sortname: 'itemvalue'}
                // , {field: 'description', title: 'description', sort: true, sortname: 'description'}
                // , {field: 'sn', title: 'sn', sort: true, sortname: 'sn'}
                // , {field: 'nodepath', title: 'nodepath', sort: true, sortname: 'nodepath'}
                // , {field: 'parentid', title: 'parentid', sort: true, sortname: 'parentid'}
                , {
                    fixed: 'right',
                    title: '管理',
                    toolbar: '#wZbztkbRightToolsBar'
                }
            ]], done: function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input', 'a[lay-event=query]', '.ccpui-enterSel');
            }
        });

        totalFilter.init('wZbztkbTable');
        dateReflash()

        function dateReflash() {
            commons.reflashDate({startName: '.start_time1', endName: '.end_time1'});
            commons.reflashDate({startName: '.start_time0', endName: '.end_time0'});
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wZbztkbTable", "wZbztkbQueryForm", {where: {}}, isClear);
        }

        table.on('toolbar(wZbztkbTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = serverPath.basePath + "/qbdms/wZbztkb/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array += data[i].dicid + ",";
                    }
                    delFun(data, array);
                    break;
                case 'export':
                    if (data.length == 0) {
                        layer.confirm('还没有选择，是否导出全部？', {
                            btn: ['确定', '取消'] //按钮
                        }, function (index) {
                            layer.close(index);
                            var url = serverPath.systemPath + '/qbdms/wZbztkb/exportData';
                            $("form[lay-filter='wZbztkbQueryForm']").find(".filter-value").each(function (i, value) {
                                if (i == 0) {
                                    url += "?" + this.name + "=" + this.value
                                } else {
                                    url += "&" + this.name + "=" + this.value
                                }
                            });
                            window.location.href = url;
                        });
                    } else {
                        layer.confirm('确定导出吗？', {
                            btn: ['是', '否'] //按钮
                        }, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = serverPath.systemPath + '/qbdms/wZbztkb/exportData?id=' + ids;
                            window.location.href = url;
                        });
                    }
                    break;
                case "import":
                    layer.open({
                        type: 2,
                        title: "导入",
                        shade: 0.3,
                        area: ['400px', '300px'],
                        content: serverPath.systemPath + "/qbdms/wZbztkb/view/import"
                        , end: function () {
                            table.reload('wZbztkbTable', {
                                page: {
                                    curr: 1
                                }
                            });
                            totalFilter.init('wZbztkbTable');
                            dateReflash();
                        }
                    });
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;

            }
            ;
        });

        table.on('tool(wZbztkbTable)', function (obj) {
            var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
            switch (layEvent) {
                case "edit":
                    window.location.href = serverPath.basePath + '/qbdms/wZbztkb/view/add?dicid=' + data.dicid
                    break;
                case "particulars":
                    window.location.href = serverPath.basePath + '/qbdms/wZbztkb/view/particulars?dicid=' + data.dicid;
                    break;
                case "del":
                    delFun(data, data.dicid);
                    break;
            }
        });

        function delFun(data, id) {
            if (data.length === 0) {
                layer.msg('请先选择一行数据!');
            } else {
                layer.confirm('确定删除当前数据吗?', function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.basePath + "/qbdms/wZbztkb/del",
                        type: "post",
                        data: {id: id},
                        dataType: 'json',
                        success: function (data) {
                            layer.alert(data.msg);
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert(data.msg);
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            dateReflash();
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wZbztkbTable", {show: window.Initialization});
    });
</script>
</body>
</html>